package com.peanut.baby.mvp.expert.intro;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.peanut.baby.R;
import com.peanut.baby.model.User;
import com.peanut.baby.mvp.BaseMvpFragment;
import com.peanut.devlibrary.util.StringUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by anonymouslystudio on 2017/7/19.
 */

public class ExpertIntroFragment extends BaseMvpFragment {

    @BindView(R.id.intro_spec)
    TextView introSpec;
    @BindView(R.id.intro_intro)
    TextView introIntro;
    Unbinder unbinder;
    private User user;

    public static ExpertIntroFragment newInstance() {
        return new ExpertIntroFragment();
    }


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_expert_intro, null);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void initData() {
        bindViewInfo();
    }

    public void setUser(User user){
        this.user = user;
        if(isActive()){
            bindViewInfo();
        }
    }

    private void bindViewInfo(){
        if(user != null){
            introSpec.setText(StringUtil.isNullOrEmpty(user.specialty)?"暂未填写":user.specialty);
            introIntro.setText(StringUtil.isNullOrEmpty(user.summary)?"暂未填写":user.summary);
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
